package cate.common.table.activity.skindraw.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.util.SplitParser;
import cate.common.util.random.RWItem;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;

public class SkinDrawPoolRow extends ERow implements RWItem {
    @NoteField("奖励")
    public String reward;
    @NoteField("权重")
    public double weight;
    @NoteField("奖励池分组")
    public int group;
    @NoteField("是否稀有")
    public boolean rare;

    @NoteField("皮肤Id")
    public int skinId;

    @Override
    public void parse(XSSFRowWrap xrw) {
        this.id = xrw.getInteger("ID");
        this.reward = xrw.getString("奖励");
        this.weight = xrw.getDouble("权重",0d);
        this.group = xrw.getInteger("奖励池分组",0);
        this.rare = xrw.getBoolean("是否稀有",false);
    }

    @Override
    public void decode() {
        if(StringUtils.isNotBlank(this.reward)) {
            String[] split = reward.split(":");
            this.skinId = Integer.parseInt(split[1]);
        }
    }

    @Override
    public double getWeight() {
        return weight;
    }
}
